<?php
declare (strict_types = 1);

namespace app\api\controller\v1;


use think\facade\Request;
use app\api\service\StatusCode;
use app\api\service\UserToken;
use app\api\validate\ParamMustBePostiveInt;
use app\api\model\BranchNode as ModelBranchNode;
use app\api\validate\Stage as ValidateStage;
/**
 * 全站的公共资源数据
 */
class BranchNode extends Api
{
   
    /**
     * 
     * 获取上级目录
     */

    public function index($week_id=null,$chapter_id=null)
    {
        if(empty($week_id) && empty($chapter_id)){
            exit(json_encode([
                'code' => 400,
                'message' => '参数错误'
            ]));
        }
        if( ! empty($week_id)){
            $week_id = (new ParamMustBePostiveInt('week_id'))->paramCheck();
        }
        if(! empty($chapter_id)){
            $chapter_id = (new ParamMustBePostiveInt('chapter_id'))->paramCheck();
        }
        $data = ModelBranchNode::getFatherName($week_id,$chapter_id);
        exit(json_encode($data));
    }
}